//queue.cpp
#include <iostream>
#include "../testNode/Node.h"
#include "../Array/Array.h"
#ifndef Queueok
#define Queueok

namespace MyStructDate{

template<class TYPE>
class QueueL{
    public:
    Node<TYPE> *back;
    _List<TYPE> start;
    Node<TYPE> Head;
    QueueL():start(NULL),back(NULL){}
    ~QueueL(){EmptyTable(start);}
    bool enqueue(TYPE info);
    bool dequeue(TYPE &info);
    bool geek(TYPE &info);
    bool isempty(){return start == NULL;}
    void makeempty(){EmptyTable(start);}
    inline QueueL<TYPE> & operator=(QueueL<TYPE> &aa){if(start==aa.start){return *this;}deepCopy(start,aa.start);return *this;}

};

template<class TYPE>
bool QueueL<TYPE>::enqueue(TYPE info){
    Node<TYPE> *ptr =new Node<TYPE>(info);
    ptr->addTail(back);
    if(start==NULL){
        start =ptr;
    }
    back = ptr;
    return true;
}

template<class TYPE>
bool QueueL<TYPE>::dequeue(TYPE &info){
    if(start!=NULL){
    info=start->getinfo();
    start->deleteNode(start);
    return true;
    }
    return false;
    
}

template<class TYPE>
bool QueueL<TYPE>::geek(TYPE &info){
    if(start == NULL){return false;}
    info =start->getinfo();
    return true;
}

// template<class TYPE>
// class QueueA{

// };

}
#endif